#!/usr/bin/python
# -*- coding: UTF-8 -*-

from datetime import datetime

""" 
@version: 1.0
@author: jin.li.o
@license: Apache Licence 
@contact: x.leevin@gmail.com
@software: PyCharm
@file: demo_market.py
@time: 2018/10/30
"""

# 4：按照以下要求定义一个游乐园门票类，并创建实例调用函数，完成儿童和大人的总票价统计（人数不定，由你输入的人数个数来决定）
# 1.平日票价100元
# 2.周末票价为平日票价120%
# 3.儿童半价

total_income = 0
child_count = 0
adult_count = 0


class AmusementPark:
    global total_income
    global child_count
    global adult_count

    base_price = 100
    isChild = False
    isWeek = False
    cur_price = 0
    enter_time = 0

    # init
    def __init__(self, is_child, enter_time):
        global total_income
        self.isChild = is_child
        # week_day = datetime.today().weekday()

        self.enter_time = enter_time
        self.calc_price(is_child, enter_time)

        total_income += self.cur_price

    # 判断是否为周末
    def is_week(self, enter_time):
        what_day = datetime.strptime(enter_time, '%Y-%m-%d %H:%M:%S')
        if what_day.weekday() > 4:
            return True
        else:
            return False

    # 计算当天每个人的门票价格
    def calc_price(self, is_child, enter_time):
        global child_count
        global adult_count

        if self.is_week(enter_time):
            self.cur_price = self.base_price * 1.2
        else:
            self.cur_price = self.base_price

        if is_child:
            self.cur_price = self.base_price * 0.5
            child_count += 1
        else:
            adult_count += 1

    # 描述
    def describe(self):
        global child_count
        global adult_count

        count = child_count + adult_count
        print("今天游园人数: {0}, 成人: {1}, 儿童: {2}, 总票价: {3}".format(count, adult_count,
                                                               child_count, total_income))


if __name__ == '__main__':
    park1 = AmusementPark(False, "2018-10-23 16:15:56")
    park2 = AmusementPark(False, "2018-10-24 16:15:56")
    park3 = AmusementPark(False, "2018-10-25 16:15:56")
    park4 = AmusementPark(False, "2018-10-26 16:15:56")
    park5 = AmusementPark(True, "2018-10-27 16:15:56")
    park5.describe()
